package vell.velllock.view;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.FontMetrics;
import android.graphics.Rect;
import android.graphics.Typeface;

public class ViewUtil {
	public void drawText(Canvas canvas, Paint mPaint, String text, int color, int size,
			Typeface typeface, Align A, int h, int w) {
		mPaint.setColor(color);
		// 抗锯齿方法
		mPaint.setAntiAlias(true);
		mPaint.setTypeface(typeface);
		mPaint.setTextSize(size);
		mPaint.setTextAlign(A);

		FontMetrics fontMetrics = mPaint.getFontMetrics();
		// 计算文字高度
		float fontHeight = fontMetrics.bottom - fontMetrics.top;

		float textBaseY = h - fontHeight / 2;
		canvas.drawText(text, w, textBaseY, mPaint);
	}
}
